﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace House.Common
{
    public class AjaxResult<T>
    {
        public static AjaxResult<T> Success(T data)
        {
            return new AjaxResult<T>
            {
                State = 1,
                ErrorMessage = "",
                Data = data
            };
        }


        public static AjaxResult<T> Fail(string message)
        {
            return new AjaxResult<T>
            {
                State = 0,
                ErrorMessage = message,
                Data = default
            };
        }

        /// <summary>
        /// 操作状态
        /// </summary>
        public int State { get; protected set; }

        /// <summary>
        /// 错误信息
        /// </summary>
        public string ErrorMessage { get; private set; }

        /// <summary>
        /// 操作结果
        /// </summary>
        public T Data { get; private set; }
    }
}
